import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'HomeView',
    component: HomeView,
  },
  {
    path: '/learnPage',
    name: 'learnPage',
    component: () => import(/* webpackChunkName: "about" */ '../views/LearnPage/LearnPage.vue')
  },
  // {
  //   path: '/show',
  //   name: 'show',
  //   component: () => import(/* webpackChunkName: "about" */ '../views/Show.vue')
  // },
  // {
  //   path: '/exchange',
  //   name: 'exchange',//聊天室
  //   component: () => import(/* webpackChunkName: "about" */ '../views/webIntri.vue')
  // },

  {
    path: '/showGua',
    name: 'showGua',
    component: () => import('@/views/showPage/GuaShow.vue')
  },
  {
    path: '/evolution',
    name: 'Evolution',
    component: () => import('@/views/showPage/Evolution.vue')
  },
  {
    path: '/money',
    name: 'Money',
    component: () => import('@/views/showPage/Money.vue')
  },
  {
    path: '/plumBlossom',
    name: 'plumBlossom',
    component: () => import('@/views/showPage/plumBlossom.vue')
  },

  {
    path: '/about',
    name: 'about',

    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },


  {
    path: '/forum',
    name: 'forum', // 论坛板块
    component: () => import(/* webpackChunkName: "about" */ '../views/ForumView.vue')
  },
  {
    path: '/login',
    name: 'Login', // 登录
    component: () => import(/* webpackChunkName: "about" */ '../views/user/Login.vue')
  },
  {
    path: '/register',
    name: 'Register', // 注册
    component: () => import(/* webpackChunkName: "about" */ '../views/user/Register.vue')
  }
]

// const router = new VueRouter({
//   mode: 'history',
//   base: process.env.BASE_URL,
//   routes
// })


// 解决  router报错 Error: Redirected when going from “/login” to “/posture” via a navigation guard. 的报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)


  return originalPush.call(this, location).catch(err => err)
}


const router = new VueRouter({
  routes
})

export default router
